﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using iShoppingDTO;
using iShoppingDAO;

namespace iShoppingBUS
{
    public class TaiKhoanBUS
    {
        //Hue
        public static DataTable LichSuDauGiaCuaTaiKhoanBUS(string _tenTaiKhoan)
        {
            return TaiKhoanDAO.LichSuDauGiaCuaTaiKhoanDAO(_tenTaiKhoan);
        }
        public static string GetTaiKhoanOfTens(string tenTaiKhoan)
        {
            return TaiKhoanDAO.GetTaiKhoanOfTens(tenTaiKhoan);
        }

        public static TaiKhoanDTO GetTaiKhoanOfTen(string tenTaiKhoan)
        {
            return TaiKhoanDAO.GetTaiKhoanOfTen(tenTaiKhoan);
        }
        public static TaiKhoanDTO GetTaiKhoanOfMa(string maTK)
        {

            return TaiKhoanDAO.GetTaiKhoanOfMa(maTK);
        }

        //dung
        public static string LayMaLoaiTK(string maTaiKhoan)
        {

            return TaiKhoanDAO.LayMaLoaiTK(maTaiKhoan);
        }
        //end

        public static bool checkTaiKhoan(TaiKhoanDTO tk)
        {
            return TaiKhoanDAO.checkTaiKhoan(tk);
        }

        public static bool insertTaiKhoan(TaiKhoanDTO tk)
        {
            return TaiKhoanDAO.insertTaiKhoan(tk);
        }

        public static bool InsertAllTaiKhoan(TaiKhoanDTO tk)
        {
            return TaiKhoanDAO.InsertAllTaiKhoan(tk);
        }

        public static bool checkTenTaiKhoan(string tenTaiKhoan)
        {
            return TaiKhoanDAO.checkTenTaiKhoan(tenTaiKhoan);
        }
        public DataTable getTaiKhoanOfMas(string maTK)
        {
            TaiKhoanDAO taiKhoanDao = new TaiKhoanDAO();
            return taiKhoanDao.getTaiKhoanOfMas(maTK);
        }

        public DataTable LoaiTaiKhoan(string maTaiKhoan)
        {
            TaiKhoanDAO taiKhoanDao = new TaiKhoanDAO();
            return taiKhoanDao.LoaiTaiKhoan(maTaiKhoan);
        }
        public bool UpdateTaiKhoanOfAvatar(TaiKhoanDTO taiKhoanDto)
        {
            TaiKhoanDAO taiKhoanDao = new TaiKhoanDAO();
            return taiKhoanDao.UpdateTaiKhoanOfAvatar(taiKhoanDto);
        }
        public bool UpdateTaiKhoanOfMatKhau(string maTK, string matKhau)
        {
            TaiKhoanDAO taiKhoanDao = new TaiKhoanDAO();
            return taiKhoanDao.UpdateTaiKhoanOfMatKhau(maTK, matKhau);
        }
         public static DataTable SelectAllTaiKhoan()
         {
             return TaiKhoanDAO.SelectAllTaiKhoan();
         }

         public static bool UpdateTaiKhoan(TaiKhoanDTO taiKhoanDto)
         {
             return TaiKhoanDAO.UpdateTaiKhoan(taiKhoanDto);
         }
         public static bool DeleteTaiKhoanofMa(string maTaiKhoan)
         {
             return TaiKhoanDAO.DeleteTaiKhoanofMa(maTaiKhoan);
         }
         public static bool UpdateTaiKhoanOfTrangThai(string maTaiKhoan,string trangThai)
         {
             return TaiKhoanDAO.UpdateTaiKhoanOfTrangThai(maTaiKhoan,trangThai);
         }

        //Hue
        public bool Khoa_MoKhoaTaiKhoanBUS(string tenTK, string tinhTrang)
        {
            TaiKhoanDAO taiKhoanDao = new TaiKhoanDAO();
            return taiKhoanDao.Khoa_MoKhoaTaiKhoanDAO(tenTK, tinhTrang);
        }

        public static TaiKhoanDTO LayThongTinTaiKhoan(string mataikhoan)
        {
            TaiKhoanDAO tkDAO = new TaiKhoanDAO();
            DataTable dt = tkDAO.getTaiKhoanOfMas(mataikhoan);
            if (dt.Rows.Count == 0)
                return null;
            TaiKhoanDTO tkDTO = new TaiKhoanDTO();
            DataRow dr = dt.Rows[0];
            tkDTO.Avatar = dr["Avatar"].ToString();
            tkDTO.DiemTinCayBan = dr["DiemTinCayBan"].ToString();
            tkDTO.DiemTinCayMua = dr["DiemTinCayMua"].ToString();
            tkDTO.TenTaiKhoan = dr["TenTaiKhoan"].ToString();
            return tkDTO;
        }

    }
}
